package com.le.basic.stringMatches;

import java.util.Arrays;

public class Code_05_BestArrange {

    public static class product{
        int start;
        int end;
        public product(int start, int end){
            this.start = start;
            this.end = end;
        }
    }

    public static int bestArrange(product[] products, int initTime){
        Arrays.sort(products,(a,b)-> a.end - b.end);
        int res = 0;
        for (int i = 0; i < products.length; i++) {
            if (initTime <= products[i].start){
                res++;
                initTime = products[i].end;
            }
        }
        return res;
    }
}
